﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SimpleRssReader.Model;
using SimpleRssReader.ViewModel;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows8Accelerator.Core.Xaml;
using Windows8Accelerator.Core.Xaml.Helpers;

namespace SimpleRssReader
{
    public sealed partial class BlogPage : Page
    {
        public BlogViewModel ViewModel
        {
            get { return DataContext as BlogViewModel; }
        }

        public BlogPage()
        {
            this.InitializeComponent();
            SuperSemanticZoomListView.PageDestinationTypeOnItemClick = typeof(PostPage);
            SuperSemanticZoomListView.ItemColumnAndRowSpanSelector = HomeViewModel.ItemColumnAndRowSpanSelector;
        }

        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            if (ViewModel == null)
            {
                DataContext = AppHelperBase.Instance.GetOrCreatePageViewModel<BlogViewModel>(this);
            }
            var secao = (Blog)e.Parameter;
            await ViewModel.LoadAsync(secao);            
        }
    }
}
